<?php

namespace app\test;

use app\common\service\around\JtkAroundService;
use app\common\service\order\CouponOrderService;
use app\common\service\pay\PayService;
use app\common\service\pay\wechat\H5;
use app\event\PaySuccess;
use app\model\CouponOrder;
use app\model\PayLog;

class OrderAroundTest
{
    /**
     * 生成已支付的订单
     */
    public function build()
    {
        //创建订单
        $couponOrder = JtkAroundService::getInstance()->createTest();


        (new PayService($couponOrder))->payByCouponOrder(new H5());


        $payLog = PayLog::query()
            ->where('order_id', $couponOrder->order_id)
            ->find();

        //支付成功事件
        event(new PaySuccess($payLog));

        $couponOrder = CouponOrder::query()
            ->where('id', $couponOrder->id)
            ->find();


        return $couponOrder;
    }

}